package com.kly.smartbi.model.enums;

import lombok.Getter;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Getter
public enum JudgeInfoMessageEnum {
    // 成功类
    SUCCESS(0, "成功"),

    // 错误类
    COMPILE_ERROR(1, "编译错误"),
    RUNTIME_ERROR(2, "运行时错误"),
    WRONG_ANSWER(3, "答案错误"),
    TIME_LIMIT_EXCEEDED(4, "超时"),
    MEMORY_LIMIT_EXCEEDED(5, "内存超限"),
    OUTPUT_LIMIT_EXCEEDED(6, "输出超限"),
    SYSTEM_ERROR(7, "系统错误"),

    // 其他状态
    JUDGING(8, "判题中"),
    PENDING(9, "等待判题");

    // 私有final属性确保不可变性
    private final int value;
    private final String text;

    // 私有构造函数强制通过枚举常量实例化
    JudgeInfoMessageEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }

    // 获取枚举值列表
    private static List<String> getValues() {
        return Stream.of(values()).map(JudgeInfoMessageEnum::getText).collect(Collectors.toList());
    }

    // 可选：通过value反向获取枚举实例
    public static JudgeInfoMessageEnum fromValue(int value) {
        for (JudgeInfoMessageEnum status : values()) {
            if (status.getValue() == value) return status;
        }
        return null;
    }
}